#include<iostream>

using namespace std;
int m[3], p[3];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= 2; ++i) {
		cin >> m[i] >> p[i];
	}
	int ans = 1e9;
	for (int i = 0; i <= 2; ++i) {
		int trp = n / m[i];
		int temp = n % m[i];
		if(temp != 0)
			trp +=1;
		ans = min(ans,trp * p[i]);

	}
	cout << ans;
	return 0;
}